package com.itheima.dao;

import com.itheima.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 用户的持久层
 */
public interface UserMapper {
    /**
     根据用户名和密码查询用户是否存在
     */
    @Select("select * from tab_user where username=#{username} and password=#{password};")
    User findUser(@Param("username") String username, @Param("password") String password);

    /**
     注册用户
     */
    @Insert("INSERT INTO tab_user VALUES (NULL, #{username}, #{password}, #{telephone});")
    int register(@Param("username") String username, @Param("password") String password, @Param("telephone") String telephone);
}
